const multerConfig = require("./multerConfig");
const fileName = "file";
const imgPath = "/public/images/";

function upload(req, res) {
  return new Promise((resolve, reject) => {
    multerConfig.array(fileName)(req, res, function (err) {
      if (err) {
        console.log(err);
        reject(err);
      } else {
        let imgArr = [];
        req.files.forEach((item) => {
          imgArr.push(imgPath + item.filename);
        });
        resolve(imgArr.toString());
      }
    });
  });
}

module.exports = upload;

